package cn.ekuma.epos.datalogic.define.dao.sale;

import cn.ekuma.data.dao.BaseDAO;
import cn.ekuma.epos.datalogic.define.dao.Product_VDAO;

import com.openbravo.bean.sales.QuickProductExt;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.TableDefinition;

public class QuickProductExtDAO extends BaseDAO<QuickProductExt> {
	Product_VDAO productDAO;
	QuickProductDAO quickProdDAO;
	public QuickProductExtDAO(I_Session s,QuickProductDAO quickProdDAO,Product_VDAO productDAO) {
	 super(s);
	 this.quickProdDAO=quickProdDAO;
	 this.productDAO=productDAO;
	}
	
	@Override
	public Class getSuportClass() {
		return QuickProductExt.class;
	}
	
	public QuickProductExt readValues(DataRead dr, QuickProductExt obj)
			throws BasicException {
		if(obj==null)
			obj=new QuickProductExt();
		quickProdDAO.readValues(dr, obj);
		obj.setProd(productDAO.find(obj.getProductId()));
		return obj;
	}

	@Override
	public TableDefinition getTable() {
		return quickProdDAO.getTable();
	}

	@Override
	public void writeInsertValues(DataWrite dp, QuickProductExt obj)
			throws BasicException {
		quickProdDAO.insert(obj);	
	}
   
}
